class Solution:
    def validateStackSequences(self, pushed: List[int], popped: List[int]) -> bool:
        if not popped:
            return True
        stack = []
        k = 0
        for i in pushed:
            stack.append(i)

            print('qian', len(stack))
            while stack and stack[-1] == popped[k]:
                stack.pop()
                k += 1
        return len(stack) == 0